<template>
  <div>
    <button @click="show">显示/隐藏</button>
    <transition name="hello" appear>
      <h1 v-show="isShow" class="text">你好</h1>
    </transition>
  </div>
</template>

<script>
export default {
  // eslint-disable-next-line vue/multi-word-component-names
  name: 'Test2',
  data() {
    return {
      isShow: true
    }
  },
  methods: {
    show() {
      this.isShow = !this.isShow
    }
  }
}
</script>

<style scoped>
.text {
  background: skyblue;
}

/*进入的起点,离开的终点*/
.hello-enter, .hello-leave-to {
  transform: translateX(-100%);
}

/*进入的终点,离开的起点*/
.hello-enter-to, .hello-leave {
  transform: translateX(0);
}

.hello-enter-active, .hello-leave-active {
  /*0.5秒的过度动画 匀速进入*/
  transition: 0.5s linear;
}
</style>
